package com.online.studyonline.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.online.studyonline.mapper.UserMapper;
import com.online.studyonline.pojo.User;
import com.online.studyonline.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class UserServioceImp extends ServiceImpl<UserMapper, User> implements UserService {
    @Autowired
    UserMapper userMapper;
    @Override
    public User getByUsername(String name) {
        QueryWrapper query = new QueryWrapper<User>()
                .eq("username",name);

        return getOne(query);
    }

    @Override
    public void addUser(String username, String password) {
        User user = new User();
        user.setUsername(username);
        user.setPasswordHash(password);
        save(user);
    }

    @Override
    public User getuser(String username) {
        return userMapper.getuser(username);
    }

    @Override
    public void update(String school, String username) {
        userMapper.stroreCall(school,username);
    }

    @Override
    public void updatePhone(String phone, String username) {
        userMapper.updatePhone(phone,username);
    }

    @Override
    public void updatePassword(String password, String username) {
        userMapper.updatePassword(password,username);
    }
}
